import 'package:flutter/material.dart';

class CommonText extends StatelessWidget {
  final String data;
  final double? fontSize;
  final FontWeight? fontWeight;
  final Color? color;
  final Color? bgColor;
  final TextAlign? textAlign;
  final TextDirection? textDirection;
  final int? maxLines;
  final TextWidthBasis? textWidthBasis;
  final TextOverflow? overflow;
  final bool canSelect;

  const CommonText({
    super.key,
    required this.data,
    this.fontSize,
    this.fontWeight,
    this.color,
    this.bgColor,
    this.textAlign,
    this.textDirection,
    this.maxLines,
    this.textWidthBasis,
    this.overflow,
    this.canSelect = false,
  });

  @override
  Widget build(BuildContext context) {
    Widget textWidget;
    if (canSelect) {
      textWidget = SelectableText(
        data,
        style: TextStyle(
            fontSize: fontSize,
            fontWeight: fontWeight,
            color: color,
            backgroundColor: bgColor,
            overflow: overflow),
        textAlign: textAlign,
        textDirection: textDirection,
        maxLines: maxLines,
        textWidthBasis: textWidthBasis,
      );
    } else {
      textWidget = Text(
        data,
        style: TextStyle(
            fontSize: fontSize,
            fontWeight: fontWeight,
            color: color,
            backgroundColor: bgColor,
            overflow: overflow),
        textAlign: textAlign,
        textDirection: textDirection,
        maxLines: maxLines,
        textWidthBasis: textWidthBasis,
      );
    }
    return textWidget;
  }
}
